import { defineStore } from 'pinia'
import { ref } from 'vue'

// 模拟课程数据
const coursesData = [
  {
    id: 1,
    title: 'Python编程入门',
    description: '零基础学习Python编程，掌握基本语法和编程思维',
    image: 'https://via.placeholder.com/300x200?text=Python',
    videos: [
      { title: '第一课：Python环境搭建', url: 'https://example.com/video1' },
      { title: '第二课：Python基本语法', url: 'https://example.com/video2' },
      { title: '第三课：Python流程控制', url: 'https://example.com/video3' }
    ]
  },
  {
    id: 2,
    title: 'Web前端开发基础',
    description: '学习HTML、CSS和JavaScript基础，构建现代化Web页面',
    image: 'https://via.placeholder.com/300x200?text=Web',
    videos: [
      { title: '第一课：HTML基础', url: 'https://example.com/web1' },
      { title: '第二课：CSS样式', url: 'https://example.com/web2' },
      { title: '第三课：JavaScript入门', url: 'https://example.com/web3' }
    ]
  },
  {
    id: 3,
    title: '数据分析实战',
    description: '使用Python进行数据分析，掌握数据可视化和处理技巧',
    image: 'https://via.placeholder.com/300x200?text=Data',
    videos: [
      { title: '第一课：数据分析概述', url: 'https://example.com/data1' },
      { title: '第二课：Pandas使用', url: 'https://example.com/data2' },
      { title: '第三课：数据可视化', url: 'https://example.com/data3' }
    ]
  },
  {
    id: 4,
    title: '微信小程序开发',
    description: '从零开始学习微信小程序开发，快速上手主流开发技术',
    image: 'https://via.placeholder.com/300x200?text=WeChat',
    videos: [
      { title: '第一课：小程序开发环境', url: 'https://example.com/wechat1' },
      { title: '第二课：小程序页面开发', url: 'https://example.com/wechat2' },
      { title: '第三课：小程序后端交互', url: 'https://example.com/wechat3' }
    ]
  }
]

export const useCourseStore = defineStore('courses', () => {
  const courses = ref(coursesData)
  
  function getCourseById(id) {
    return courses.value.find(course => course.id === Number(id))
  }
  
  return {
    courses,
    getCourseById
  }
}) 